1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package net.sf.pmr.agilePlanning.domain.iteration;
37
38 import java.util.Calendar;
39 import java.util.Date;
40
41 import net.sf.pmr.agilePlanning.domain.release.Release;
42 import net.sf.pmr.core.domain.basicProject.BasicProject;
43 import net.sf.pmr.keopsframework.domain.object.AbstractDomainObject;
44
45 import org.apache.commons.lang.builder.EqualsBuilder;
46 import org.apache.commons.lang.builder.HashCodeBuilder;
47
48 /***
49 * @author Arnaud Prost (arnaud.prost@gmail.com)
50 */
51 public class IterationImpl extends AbstractDomainObject implements Iteration {
52
53 /***
54 * basic Project
55 */
56 private BasicProject basicProject;
57
58 /***
59 * start
60 */
61 private Date start;
62
63 /***
64 * end
65 */
66 private Date end;
67
68 /***
69 * release
70 */
71 private Release release;
72
73 /***
74 * @see net.sf.pmr.agilePlanning.domain.iteration.Iteration#getBasicProject()
75 */
76 public BasicProject getBasicProject() {
77 return basicProject;
78 }
79
80 /***
81 * @see net.sf.pmr.agilePlanning.domain.iteration.Iteration#setBasicProject(net.sf.pmr.core.domain.basicProject.BasicProject)
82 */
83 public void setBasicProject(final BasicProject basicProject) {
84 this.basicProject = basicProject;
85 }
86
87 /***
88 * @see net.sf.pmr.agilePlanning.domain.iteration#getStart()
89 */
90 public Date getStart() {
91 return start;
92 }
93
94 /***
95 * La date est tronquée au jour
96 *
97 * @see net.sf.pmr.agilePlanning.domain.iteration#setStart(java.util.Date)
98 */
99 public void setStart(final Date start) {
100
101 this.start = roundDateToDay(start);
102
103 }
104
105 /***
106 * @see net.sf.pmr.agilePlanning.domain.iteration#getEnd()
107 */
108 public Date getEnd() {
109 return end;
110 }
111
112 /***
113 * La date est tronquée au jour
114 *
115 * @see net.sf.pmr.agilePlanning.domain.iteration#setEnd(java.util.Date)
116 */
117 public void setEnd(final Date end) {
118
119 this.end = roundDateToDay(end);
120
121 }
122
123 /***
124 * @see net.sf.pmr.agilePlanning.domain.iteration#getRelease()
125 */
126 public Release getRelease() {
127 return this.release;
128 }
129
130 /***
131 * @see net.sf.pmr.agilePlanning.domain.iteration#setRelease(net.sf.pmr.agilePlanning.domain.Release)
132 */
133 public void setRelease(final Release release) {
134 this.release = release;
135 }
136
137
138 /***
139 * Arrondi la date donnée au jour Le nombre de milliseconde est positionné à
140 * 1 (pour ne pas changer de date si on est à minuit)
141 *
142 * @param date
143 * à arrondir
144 * @return date arrondi
145 */
146 private Date roundDateToDay(final Date date) {
147
148 if (date != null) {
149
150 Calendar calendar = Calendar.getInstance();
151
152 calendar.setTime(date);
153
154 calendar.set(Calendar.HOUR_OF_DAY, 0);
155 calendar.set(Calendar.MINUTE, 0);
156 calendar.set(Calendar.SECOND, 0);
157 calendar.set(Calendar.MILLISECOND, 1);
158
159 return calendar.getTime();
160
161 } else {
162
163 return date;
164
165 }
166
167 }
168 /***
169 * @see java.lang.Object#equals(Object)
170 */
171 public boolean equals(final Object object) {
172 if (!(object instanceof IterationImpl)) {
173 return false;
174 }
175 IterationImpl rhs = (IterationImpl) object;
176 return new EqualsBuilder().append(this.basicProject, rhs.basicProject)
177 .append(this.start, rhs.start)
178 .append(this.end, rhs.end)
179 .isEquals();
180 }
181 /***
182 * @see java.lang.Object#hashCode()
183 */
184 public int hashCode() {
185 return new HashCodeBuilder(522268527, -355299201).append(this.basicProject)
186 .append(this.start)
187 .append(this.end)
188 .toHashCode();
189 }
190 }